<template>
  <div>
    <div id="main" style="width: 600px; height: 400px"></div>
  </div>
</template>
<script>
var echarts = require("echarts");
export default {
  data() {
    return {
      option: {
        series: [
          {
            type: "gauge",
            axisLine: {
              lineStyle: {
                width: 20,
                color: [
                  [0.3, "#67e0e3"],
                  [0.7, "#37a2da"],
                  [1, "#fd666d"],
                ],
              },
            },
            pointer: {
              itemStyle: {
                color: "auto",
              },
            },
            axisTick: {
              distance: -30,
              length: 8,
              lineStyle: {
                color: "#fff",
                width: 2,
              },
            },
            splitLine: {
              distance: -30,
              length: 30,
              lineStyle: {
                color: "#fff",
                width: 4,
              },
            },
            axisLabel: {
              color: "auto",
              distance: 40,
              fontSize: 20,
            },
            detail: {
              valueAnimation: true,
              color: "auto",
            },
            data: [
              {
                value: 80,
              },
            ],
          },
        ],
      },
    };
  },
  methods: {
    set() {
      let myChart = echarts.init(document.getElementById("main"));
      myChart.clear(); //如果图表有修改需求建议加上此方法先清后画
      myChart.setOption(this.option);
    },
  },
  mounted() {
    this.set();
  },
};
</script>
<style scoped></style>
